import java.util.Scanner;

public class Main {
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
//        String s = in.nextLine();
//        int n = in.nextInt();
        String s = "AACTGTGCACGACCTGA";
        int n = 5;
        int m = s.length();
        double x = 0, tmp = 0x3f3f3f3f;
        StringBuffer buf = new StringBuffer();
        StringBuffer ret = new StringBuffer();

        for(int i = 0; i < m; i++){
            char get = s.charAt(i);
            if(get == 'C' || get == 'G') { x++;}
            buf.append(in);
            if(i < n - 1) { continue;}
            if(tmp > (x / m)){
                tmp = x / m;
                ret = buf;
            }
            char out = s.charAt(i - n + 1);
            if(out == 'C' || out == 'G'){
                x--;
            }
            buf.deleteCharAt(0);
        }
        System.out.println(ret.toString());
    }

    public String formatString (String str, char[] arg) {
        StringBuffer ret = new StringBuffer();
        char[] s = str.toCharArray();

        int j = 0;
        for(int i = 0; i < str.length(); i++){
            if(s[i] != '%'){
                ret.append(s[i]);
            }else{
                if(i + 1 < str.length() && s[i + 1] == 's'){
                    ret.append(arg[j++]);
                    i++;
                }else{
                    ret.append(s[i]);
                }
            }
        }
        while(j < arg.length){
            ret.append(arg[j++]);
        }
        return ret.toString();
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt(), b = in.nextInt();

        int ret = 0;
        for(int i = Math.max(a, 10); i <= b; i++){
            ret += check(i);
        }
        System.out.println(ret);
    }

    public static int check(int x){
        int[] num = new int[10];
        int n = 0;
        while(x != 0){
            num[n++] = x % 10;
            x /= 10;
        }
        for(int i = 0; i< n; i++){
            for(int j = 0; j < n; j++){
                if(num[i] != 0 && i != j){
                    if(isPrim(num[i] * 10 + num[j])){
                        return 1;
                    }
                }
            }
        }
        return 0;
    }

    public static boolean isPrim(int x){
        if(x < 2) { return false;}
        for(int i = 2; i < Math.sqrt(x); i++){
            if(x % i == 0) { return true;}
        }
        return false;
    }




































}